<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="author" content="jxm">
    <script src="../jQuery/jquery-3.1.1.js"></script>
    <title>选项卡</title>
    <style>
        main{
            width: 600px;
            margin: 50px auto;
            border: 1px solid #999;
            background-color: whitesmoke;
        }
        div{
            width: 600px;
            height: 50px;
            background-color: black;
            color: white;
            font-size: 24px;
        }
        div span{
            display: inline-block;
            width: 150px;
            height: 50px;
            line-height: 50px;
            text-align: center;
            float: left;
        }
        ul{
            padding: 0;
            margin: 0;
            list-style: none;
            width: 100px;
            margin: 10px auto;
            display: none;
        }
        li{
            height: 40px;
            text-align: center;
            font-size: 24px;
        }
        .active{
            display: block;
        }
        .select{
            background-color: #fff;
            color: black;
        }
    </style>
</head>
<body>
    <main>
        <div>
            <span class="select">选项一</span>
            <span>选项二</span>
            <span>选项三</span>
        </div>
        <ul class="active">
            <li>内容1</li>
            <li>内容2</li>
        </ul>
        <ul>
            <li>内容1</li>
            <li>内容2</li>
            <li>内容3</li>
        </ul>
        <ul>
            <li>内容1</li>
            <li>内容2</li>
            <li>内容3</li>
            <li>内容4</li>
            <li>内容5</li>
        </ul>
    </main>
</body>
<html>
<script>
    $('div span').each(function(index){

        $(this).mouseover(function(){

            $('ul').eq(index).toggleClass('active').siblings().removeClass('active');
            $(this).toggleClass('select').siblings().removeClass('select');

        })
    })
</script>
